package com.youshang520i.springcommonmiddleware.controller;

import com.youshang520i.springcommonmiddleware.service.RocketmqService;
import com.youshang520i.springcommonmiddleware.mq.rabbitmq.po.Mail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author youshang
 */
@RestController
public class RocketMQController {


    @Autowired
    private RocketmqService mqService;

    @PostMapping("/")
    public String send(@RequestBody Mail mail){
        if (null == mail){
            return "请求参数为null!!!";
        }
        boolean send = mqService.send(mail);
        return send ? "成功" : "失败";
    }

    @PostMapping("/broadcast")
    public String broadcast(@RequestBody Mail mail){
        if (null == mail){
            return "请求参数为null!!!";
        }
        boolean send = mqService.sendBroadcast(mail);
        return send ? "成功" : "失败";
    }

}
